﻿@model LYZJ.HM3Shop.Model.ActionGroup

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>SetRole</title>
    <script src="../../Scripts/jquery-1.7.1.js"></script>
    <script src="../../Scripts/jquery.unobtrusive-ajax.js"></script>
    <script type="text/javascript">
        function AfterSetActionGroupRole(data) {
            if (data == "OK") {
                window.parent.AfterSetActionGroupRole();
            }
            else {
                alert("菜单项角色设置失败，请您检查");
            }
        }
    </script>
</head>
<body>
    <h3>欢迎您给菜单组:<font color="red" size="3">@Model.GroupName </font>设置角色信息:</h3>
    <hr />
    <fieldset>
        <legend>设置菜单项的角色信息</legend>
        @using (Ajax.BeginForm("SetRole", "ActionGroup", new AjaxOptions() { OnSuccess = "AfterSetActionGroupRole" }, new { ID = "frmSetRole" }))
        {
            <input type="hidden" name="HidenID" value="@Model.ID" />
            
            List<LYZJ.HM3Shop.Model.Role> allRoles = (List<LYZJ.HM3Shop.Model.Role>)ViewBag.RoleInfo;
            List<int> Exist = (List<int>)ViewBag.exists;
            //循环遍历出角色信息显示在菜单中
            for (int i = 0; i < allRoles.Count; i++)
            {
                string str = "al_" + allRoles[i].ID;
                if (i % 3 == 0)
                {
                    <br />
                }
                if (Exist.Contains(allRoles[i].ID))
                {
                    <input type="checkbox" checked="checked" name="@str" value="@str" id="@str" />
                }
                else
                {
                     <input type="checkbox" name="@str" value="@str" id="@str" />
                }
                <label for="@str">@allRoles[i].RoleName</label><span>&nbsp;&nbsp;</span>
            }
            <br />
            <div style="text-align:center;">
                <input type="submit" value="设置菜单项角色" />
            </div>
        }
    </fieldset>
</body>
</html>
